﻿Imports System
Imports System.IO
Imports System.Data.OleDb
Imports System.Data
Imports System.Drawing
Imports System.Drawing.Imaging
Namespace Arwani
    Partial Class Backend_AddNewExhibition
        Inherits System.Web.UI.Page

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If (Session("ADMIN_USER") IsNot Nothing) Then
                If Page.IsPostBack Then Exit Sub
                If Request.QueryString("id") <> "0" Then
                    Call getPageSEOInformationById(Request.QueryString("id").ToString())
                End If
            Else
                Response.Redirect("Default.aspx")
            End If

        End Sub
        Public Function CheckPageExistance() As Boolean

            Dim strQ As String
            Dim arwCon As New ArwaniController
            Dim count As String

            strQ = "select count(*) as countTitle  from AddSEO where PageName='" & Me.txtPageName.Text & "'"
            Dim dtTable As DataTable = arwCon.ExecuteQuery(strQ)
            count = dtTable.Rows(0)("countTitle").ToString()
            If (count > 1) Then
                Return True
            Else
                Return False
            End If

        End Function

        Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
            Dim strQ As String
            Dim arwCon As New ArwaniController
           
           
            If (CheckPageExistance()) Then
                lblError.Text = "Page Name already Exists !"
            Else
                strQ = "update AddSEO set Title='" & txtTitle.Text & "', PageName='" & txtPageName.Text.ToLower() & "', Description='" & txtDescription.Text & "',keywords='" & txtKeywords.Text & "' where id=" & Val(Request.QueryString("id"))
                arwCon.ExecuteNonQuery(strQ)
                Response.Redirect("ManagePageSEO.aspx")
            End If

        End Sub


        Public Sub getPageSEOInformationById(ByVal Id As String)
            Dim arwCon As New ArwaniController
            Dim strQ As String = "select * from AddSEO where id=" & Id
            Dim dtTable As DataTable = arwCon.ExecuteQuery(strQ)
            If dtTable.Rows.Count > 0 Then
                If Not IsDBNull(dtTable.Rows(0)("Title")) Then Me.txtTitle.Text = dtTable.Rows(0)("Title")
                If Not IsDBNull(dtTable.Rows(0)("keywords")) Then Me.txtKeywords.Text = dtTable.Rows(0)("keywords")
                If Not IsDBNull(dtTable.Rows(0)("PageName")) Then Me.txtPageName.Text = dtTable.Rows(0)("PageName")
                If Not IsDBNull(dtTable.Rows(0)("Description")) Then Me.txtDescription.Text = dtTable.Rows(0)("Description")
            End If
        End Sub

        Protected Sub btnCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCancel.Click
            Response.Redirect("ManagePageSEO.aspx")
        End Sub
    End Class
End Namespace